require("@babel/register")
const Koa = require('koa')
const app = new Koa()
const routes = require('./middleware/routes')
const bodyParser = require('koa-bodyparser')
const configs = require('./configs')
const globalInterceptor = require('./middleware/global/globalInterceptor')

// 全局错误处理中间件
app.use(globalInterceptor.errorInterceptor);
// 是否认证过滤器
app.use(globalInterceptor.authInterceptor);

// 使用ctx.body解析中间件
app.use(bodyParser())

// 加载路由中间件
app.use(routes.routes()).use(routes.allowedMethods())

app.use(globalInterceptor.isNotFoundRouter)

app.listen(configs.port)
console.log(`project start-quick is starting at http://localhost:${configs.port}`)